// 权限管理接口
import request from '@/utils/request'
import { Permission, ResAllPermission } from './type'
enum API {
  all_permission = '/admin/acl/permission',
  add_permission = '/admin/acl/permission/save',
  update_permission = '/admin/acl/permission/update',
  delete_permission = '/admin/acl/permission/remove/',
}

// 获取全部权限
export const reqAllPermission = () =>
  request.get<any, ResAllPermission>(API.all_permission)

// 添加/修改权限
export const reqAddOrUpdatePermission = (data: Permission) => {
  if (data.id) return request.put<Permission, any>(API.update_permission, data)
  return request.post<Permission, any>(API.add_permission, data)
}

// 删除权限
export const reqDeletePermission = (id: number) =>
  request.delete(API.delete_permission + id)
